<template>
  <div class="container">
    <!-- 头部 -->
    <van-nav-bar
      fixed
      v-if="isShowTop"
      title="明日头条"
      right-text="搜索"
      @click-right="$router.push('/search')"
    />
    <div class="my-wrapper" :class="{ noTop: !isShowTop }">
      <!-- 二级路由挂载点 -->
      <router-view />
    </div>
    <!-- 标签栏=》菜单 -->
    <van-tabbar route>
      <van-tabbar-item to="/" icon="home-o">首页</van-tabbar-item>
      <van-tabbar-item to="/question" icon="search">问答</van-tabbar-item>
      <van-tabbar-item to="/video" icon="home-o">视频</van-tabbar-item>
      <van-tabbar-item to="/user" icon="search">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  computed: {
    isShowTop () {
      return this.$route.path !== '/user'
    }
  }
}
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  position: relative;
  .my-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding-top: 46px;
    padding-bottom: 50px;
    box-sizing: border-box;
    &.noTop {
      padding-top: 0;
    }
  }
}
</style>
